package com.eascs.app.dao;

import java.lang.reflect.Field;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;

import com.eascs.app.context.RSADecoder;
import com.eascs.common.util.ClassUtil;

public class DataSourceSetting {

	@XmlElement(name = "jdbc.driver", required = true)
	private String driver;
	@XmlElement(name = "jdbc.url", required = true)
	private String url;
	@RSADecoder
	@XmlElement(name = "jdbc.password", required = false)
	private String password;
	//@RSADecoder
	@XmlElement(name = "jdbc.username", required = true)
	private String username;
	@XmlElement(name = "jdbc.sqlDialect", required = true)
	private String sqlDialect;
	@XmlElement(name = "jdbc.databaseName", required = true)
	private String databaseName;
	@XmlElement(name = "jdbc.validationQuery", required = true)
	private String validationQuery;

	public String getDriver() {
		return driver;
	}

	public void setDriver(String driver) {
		this.driver = driver;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getSqlDialect() {
		return sqlDialect;
	}

	public void setSqlDialect(String sqlDialect) {
		this.sqlDialect = sqlDialect;
	}

	public String getDatabaseName() {
		return databaseName;
	}

	public void setDatabaseName(String databaseName) {
		this.databaseName = databaseName;
	}

	public String getValidationQuery() {
		return validationQuery;
	}

	public void setValidationQuery(String validationQuery) {
		this.validationQuery = validationQuery;
	}

	public static void main(String[] args) throws NoSuchFieldException, SecurityException {
		Field field = DataSourceSetting.class.getDeclaredField("username");
		System.out.println(field.getDeclaredAnnotation(RSADecoder.class));
		System.out.println(field.getDeclaredAnnotation(RSADecoder.class));
		List<Field> fields = ClassUtil.findAnnotationFields(DataSourceSetting.class, RSADecoder.class);
		System.out.println("fields:" + (fields == null) + " " + fields.size());
		for (Field f : fields) {
			System.out.println(f.getName());
		}
	}
}
